﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using nRoute.Navigation;
using nRoute.Components;

namespace SimpleShell
{
    public partial class Shell : UserControl, ISupportNavigationViewState
    {
        public Shell()
        {
            InitializeComponent();
        }

        public void RestoreState(nRoute.Components.ParametersCollection state)
        {

            var _leftState = state.GetValueOrDefault("LEFT", default(ParametersCollection));
            var _rightState = state.GetValueOrDefault("RIGHT", default(ParametersCollection));
            if (_leftState != null) ((ISupportNavigationViewState)leftContainer).RestoreState(_leftState);
            if (_rightState != null) ((ISupportNavigationViewState)rightContainer).RestoreState(_rightState);
        }

        public nRoute.Components.ParametersCollection SaveState()
        {
            return new ParametersCollection()
            {
                new Parameter("LEFT", ((ISupportNavigationViewState)leftContainer).SaveState()),
                new Parameter("RIGHT", ((ISupportNavigationViewState)rightContainer).SaveState()),
            };
        }
    }
}
